package demo1;

public class Test1 {
    public static void main(String[] args) throws InterruptedException {
//        Thread t1 = new Thread(new Runnable() {
//            @Override
//            public void run() {
//                while(true){
//                    System.out.println("t1");
//                    try {
//                        Thread.sleep(1000);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        });
//        t1.start();
//        System.out.println(t1.getState());
//        System.out.println(t1.getId());
//        while(true){
//            System.out.println("main");
//              Thread.sleep(1000);
//        }
        Thread t1 = new Thread(()->{
            while(true){
                System.out.println("T1线程");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        System.out.println(t1.isAlive());
        System.out.println(t1.getState());
        t1.setDaemon(true);
        t1.start();
        System.out.println(t1.getState());
        System.out.println("t1是否是后台线程"+t1.isDaemon());
        System.out.println(t1.isAlive());
        System.out.println("main结束");
    }
}
